layui.define(['setter','auth'], function (exports) {
    var setter = layui.setter
        , $ = layui.$;


    //定时获取七牛token
    var getQiniuToken = function () {
        $.ajax({
            url: setter.apiHost + "/api/qiniu/token"
            , type: "get"
        }).done(function (res) {
            localStorage.setItem("QiniuToken", res.token);
            console.log("更新七牛token成功")
        }).fail(function (err) {
            setTimeout(function () {
                getQiniuToken();
                console.warn("获取token失败");
            }, 5000)
        })
    }
    //立即执行一次
    getQiniuToken();
    //每50分钟执行一次
    setInterval(function () {
        getQiniuToken();
    }, 1000 * 60 * 50)


    exports("schedule", {})
})